|
RAIS
3.2
|
00001 00028 using System; 00029 using System.Data; 00030 using System.Configuration; 00031 using System.Collections; 00032 using System.Web; 00033 using System.Web.Security; 00034 using System.Web.UI; 00035 using System.Web.UI.WebControls; 00036 using System.Web.UI.WebControls.WebParts; 00037 using System.Web.UI.HtmlControls; 00038 using System.Net; 00039 using System.IO; 00040 00041 using RAIS.Common.UserManagement; 00042 using System.Drawing; 00043 //using RAIS.ApplicationLogicLayer; 00044 00045 namespace RAIS.UI.SpecificMasks 00046 { 00050 public partial class MainImport : System.Web.UI.Page 00051 { 00052 //********************************************************************* 00053 #region Properties 00054 00057 protected UserData CurrentUser 00058 { 00059 get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; } 00060 } 00061 #endregion 00062 00063 #region Event handlers 00064 protected void Page_PreLoad(object sender, EventArgs e) 00065 { 00066 RAIS.UI.Common.PageManagement.TrimTextBoxValues(this); 00067 } 00074 protected void Page_Load(object sender, EventArgs e) 00075 { 00076 this.Response.Cache.SetNoStore(); 00077 if (this.CurrentUser == null) 00078 UI.Common.AccessManagement.SignOut(this); 00079 InitPanels(); 00080 if (!this.IsPostBack) 00081 { 00082 this.LBLusernameNoTranslation.Text = this.CurrentUser.Name; 00083 LBLerror.Text = "Please enter a text to search for"; 00084 LBLnoPassword.Text = "Please enter password"; 00085 LBLnoLogin.Text = "Please enter login name"; 00086 LBLloginerror.Text = "Login failed"; 00087 00088 UI.Common.PageManagement.InitializePage(this, this.TreeView1); 00089 // this.LBTNmessagebox.Visible = !(this.CurrentUser.FunctionalRole.Type == FunctionRole.FunctionRoleType.Guest); 00090 } 00091 this.LBLinput.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT; 00092 // this.LBTNmessagebox.Visible = !(this.CurrentUser.FunctionalRole.Type == FunctionRole.FunctionRoleType.Guest); 00093 // InitPanels(); 00094 UI.Common.PageManagement.InitHelpMainMenu(LBTNdefault); 00095 } 00102 protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) 00103 { 00104 UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1); 00105 } 00106 00113 protected void LBTNlogout_Click(object sender, EventArgs e) 00114 { 00115 UI.Common.AccessManagement.SignOut(this); 00116 } 00117 00118 /* 00119 * This method is called by clicking the “Search” Button on “MainImport.aspx”. 00120 * It checks whether the search text is entered or not and redirects to 00121 * “Import.aspx” with two attributes appended at the URL: The search text 00122 * and the type of object you want to search for. These attributes are needed 00123 * by “Import.aspx.cs” to return the search result! 00124 * 00125 */ 00126 protected void BTNsearch_Click(object sender, EventArgs e) 00127 { 00128 LBLerror.Visible = false; 00129 if (!TXTtext.Text.Equals("")) // Redirect to "Import.aspx" and display search result 00130 { 00131 string url = String.Format("Import.aspx?&search={0}&type={1}", TXTtext.Text, DDLtype.SelectedValue); 00132 Response.Redirect(url); 00133 } 00134 else // display error message 00135 { 00136 LBLerror.Visible = true; 00137 } 00138 } 00139 00140 private bool LoginFailed(string login, string pass) 00141 { 00142 string url = string.Format("https://icsrs.iaea.org/rais_search.aspx?username={0}&pwd={1}" 00143 , login 00144 , pass); 00145 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); 00146 webRequest.KeepAlive = false; 00147 webRequest.Method = "GET"; 00148 HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); 00149 00150 string resp = new StreamReader(webResponse.GetResponseStream()).ReadToEnd(); 00151 webResponse.Close(); 00152 return resp == "Login failed!"; 00153 } 00154 00155 protected void BTNLogin_Click(object sender, EventArgs e) 00156 { 00157 LBLnoLogin.Visible = false; 00158 LBLnoPassword.Visible = false; 00159 LBLloginerror.Visible = false; 00160 bool error = false; 00161 00162 if (TXTLogin.Text.Trim() != "") 00163 { 00164 Session[RAIS.UI.Common.Constants.IcSRS_LOGIN_TAG] = TXTLogin.Text; 00165 } 00166 else 00167 { 00168 Session[RAIS.UI.Common.Constants.IcSRS_LOGIN_TAG] = null; 00169 LBLnoLogin.Visible = true; 00170 error = true; 00171 } 00172 if (TXTPass.Text.Trim() != "") 00173 { 00174 Session[RAIS.UI.Common.Constants.IcSRS_PASSWORD_TAG] = TXTPass.Text; 00175 } 00176 else 00177 { 00178 Session[RAIS.UI.Common.Constants.IcSRS_PASSWORD_TAG] = null; 00179 LBLnoPassword.Visible = true; 00180 error = true; 00181 } 00182 if (!error && LoginFailed(TXTLogin.Text, TXTPass.Text)) 00183 { 00184 LBLloginerror.Visible = true; 00185 Session[RAIS.UI.Common.Constants.IcSRS_LOGIN_TAG] = null; 00186 Session[RAIS.UI.Common.Constants.IcSRS_PASSWORD_TAG] = null; 00187 error = true; 00188 } 00189 00190 InitPanels(); 00191 } 00192 protected void BTBLogout_Click(object sender, EventArgs e) 00193 { 00194 Session[RAIS.UI.Common.Constants.IcSRS_LOGIN_TAG] = null; 00195 Session[RAIS.UI.Common.Constants.IcSRS_PASSWORD_TAG] = null; 00196 InitPanels(); 00197 } 00198 00199 #endregion 00200 00201 #region Private helper methods 00202 00203 private void InitPanels() 00204 { 00205 if (Session[RAIS.UI.Common.Constants.IcSRS_LOGIN_TAG] == null || Session[RAIS.UI.Common.Constants.IcSRS_PASSWORD_TAG] == null) 00206 { 00207 loginPan.Visible = true; 00208 connectPan.Visible = false; 00209 LBLimport.Visible = false; 00210 LBLicsrsLogin.Visible = true; 00211 TXTLogin.Focus(); 00212 } 00213 else 00214 { 00215 loginPan.Visible = false; 00216 connectPan.Visible = true; 00217 //LBLimport.Text = string.Format("Data Import from IcSRS (login: {0})", Session[RAIS.UI.Common.Constants.IcSRS_LOGIN_TAG]); 00218 LBLicsrsLogin.Visible = false; 00219 LBLimport.Visible = true; 00220 LBLicsrsUserNameNoTranslation.Text = string.Format("({0})", Session[RAIS.UI.Common.Constants.IcSRS_LOGIN_TAG]); 00221 TXTtext.Focus(); 00222 } 00223 } 00224 #endregion 00225 } 00226 }